package com.amex.uam.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.amex.uam.dao.AmexBusDao;
import com.amex.uam.model.AMEX_BUSINESS;
import com.amex.uam.model.Message;
import com.amex.uam.service.AmexBusService;

@Service("amexBusService")
public class AmexBusServiceImpl implements AmexBusService {
	
	private AmexBusDao amexBusDao;
	@Resource
	public void setAmexBusDao(AmexBusDao amexBusDao) {
		this.amexBusDao = amexBusDao;
	}
	
	@Override
	public Message addBusiness(AMEX_BUSINESS bus) {
		throw new RuntimeException(this.getClass().getSimpleName() + ".addBusiness not implemented");
	}

	@Override
	public Message deleteBusiness(String busCd) {
		throw new RuntimeException(this.getClass().getSimpleName() + ".deleteBusiness not implemented");
	}

	@Override
	public Message updateBusiness(AMEX_BUSINESS bus) {
		if (bus == null) {
			return new Message(Message.ERROR_PARAM);
		}
		if (bus.getAMEX_BUS_CD() == null || bus.getAMEX_BUS_CD().equals("")) {
			return new Message(Message.ERROR_PARAM);
		}
		
		boolean success = amexBusDao.updateBusiness(bus);
		return success ? new Message(Message.OK) : new Message(Message.ERROR);
	}

	@Override
	public Message getBusiness(String busCd) {
		throw new RuntimeException(this.getClass().getSimpleName() + ".getBusiness not implemented");
	}

}
